<fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
    <legend>修改密码</legend>
</fieldset>

<form class="layui-form layui-form-pane" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">当前密码</label>
        <div class="layui-input-inline">
            <input type="password" name="old_pwd" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-inline">
            <input type="password" name="new_pwd" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">新密码确认</label>
        <div class="layui-input-inline">
            <input type="password" name="new_pwd_confirm" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="reset_password">立即提交</button>
            <button id="resetPwdBtn" type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script type="text/javascript">
    layui.use(['form', 'ajaxUtil'], function(){
        var form = layui.form();
        var ajaxUtil = layui.ajaxUtil;
        var commonUtil = layui.commonUtil;
        var $ = layui.jquery;

        var urls = {};
        urls.reset_password = '/admin/adminuser/reset-password';

        //监听提交
        form.on('submit(reset_password)', function(data){
            ajaxUtil.doAjaxGet(urls.reset_password,data.field).done(function(ret) {
                if(ret.status == 0) {
                    $('#resetPwdBtn').trigger('click');

                    commonUtil.toast(ret.msg);
                } else {
                    commonUtil.toast(ret.msg);
                }
            });
            return false;
        });
    });
</script>